package cn.xaut.数组;

import java.util.Arrays;

public class demo283 {

    public void moveZeroes(int[] nums) {

        int index = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != 0)
                nums[index++] = nums[i];
        }
        for (int i = index; i < nums.length; i++) 
            nums[i] = 0;
    }

    public static void main(String[] args) {

        int[] nums = new int[]{0, 1, 0, 3, 12};
        new demo283().moveZeroes(nums);
        System.out.println(Arrays.toString(nums));
    }
}
